<?php

/**
 * AbetStudent form base class.
 *
 * @method AbetStudent getObject() Returns the current form's model object
 *
 * @package    sfproject
 * @subpackage form
 * @author     Your name here
 */
abstract class BaseAbetStudentForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'dep_code'     => new sfWidgetFormPropelChoice(array('model' => 'AbetDepartment', 'add_empty' => true)),
      'stu_code'     => new sfWidgetFormInputHidden(),
      'ins_code'     => new sfWidgetFormPropelChoice(array('model' => 'AbetInstructor', 'add_empty' => true)),
      'password'     => new sfWidgetFormInputText(),
      'first_name'   => new sfWidgetFormInputText(),
      'mid_name'     => new sfWidgetFormInputText(),
      'grand_name'   => new sfWidgetFormInputText(),
      'last_name'    => new sfWidgetFormInputText(),
      'start_date'   => new sfWidgetFormDate(),
      'level_number' => new sfWidgetFormInputText(),
      'ssn'          => new sfWidgetFormInputText(),
      'birth_date'   => new sfWidgetFormDate(),
      'sex'          => new sfWidgetFormInputText(),
      'degree'       => new sfWidgetFormInputText(),
      'gpa'          => new sfWidgetFormInputText(),
      'email'        => new sfWidgetFormInputText(),
      'phone'        => new sfWidgetFormInputText(),
      'mobile'       => new sfWidgetFormInputText(),
      'city'         => new sfWidgetFormInputText(),
      'street'       => new sfWidgetFormInputText(),
      'pobox'        => new sfWidgetFormInputText(),
      'created_at'   => new sfWidgetFormDateTime(),
      'updated_at'   => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'dep_code'     => new sfValidatorPropelChoice(array('model' => 'AbetDepartment', 'column' => 'dep_code', 'required' => false)),
      'stu_code'     => new sfValidatorChoice(array('choices' => array($this->getObject()->getStuCode()), 'empty_value' => $this->getObject()->getStuCode(), 'required' => false)),
      'ins_code'     => new sfValidatorPropelChoice(array('model' => 'AbetInstructor', 'column' => 'ins_code', 'required' => false)),
      'password'     => new sfValidatorString(array('max_length' => 20)),
      'first_name'   => new sfValidatorString(array('max_length' => 20)),
      'mid_name'     => new sfValidatorString(array('max_length' => 20)),
      'grand_name'   => new sfValidatorString(array('max_length' => 20)),
      'last_name'    => new sfValidatorString(array('max_length' => 20)),
      'start_date'   => new sfValidatorDate(),
      'level_number' => new sfValidatorString(array('max_length' => 2)),
      'ssn'          => new sfValidatorString(array('max_length' => 20)),
      'birth_date'   => new sfValidatorDate(),
      'sex'          => new sfValidatorString(array('max_length' => 10)),
      'degree'       => new sfValidatorString(array('max_length' => 20)),
      'gpa'          => new sfValidatorNumber(),
      'email'        => new sfValidatorString(array('max_length' => 30)),
      'phone'        => new sfValidatorString(array('max_length' => 9)),
      'mobile'       => new sfValidatorString(array('max_length' => 10)),
      'city'         => new sfValidatorString(array('max_length' => 20)),
      'street'       => new sfValidatorString(array('max_length' => 30)),
      'pobox'        => new sfValidatorString(array('max_length' => 20)),
      'created_at'   => new sfValidatorDateTime(array('required' => false)),
      'updated_at'   => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'AbetStudent', 'column' => array('ssn'))),
        new sfValidatorPropelUnique(array('model' => 'AbetStudent', 'column' => array('email'))),
        new sfValidatorPropelUnique(array('model' => 'AbetStudent', 'column' => array('mobile'))),
        new sfValidatorPropelUnique(array('model' => 'AbetStudent', 'column' => array('pobox'))),
      ))
    );

    $this->widgetSchema->setNameFormat('abet_student[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'AbetStudent';
  }


}
